package edu.gatech.app4args.utils;

import java.io.File;

/**
 * Used by the FileChooser on import to filter out non xml files.
 *
 * @author Andrew Lunsford
 */
public class XMLFileFilter extends javax.swing.filechooser.FileFilter {

	/**
	 * The file to test for filter compliance. Only accepts xml files.
	 *
	 * @param file the file to filter
	 * @return true if it is an xml file
	 */
	@Override
	public boolean accept(File file) {
		// Allow only directories, or files with ".xml" extension
		return file.isDirectory() || file.getAbsolutePath().endsWith(".xml");
	}

	/**
	 * Sets the description in the FileChooser dropdown for file types.
	 *
	 * @return the xml filter string
	 */
	@Override
	public String getDescription() {
		return "XML files (*.xml)";
	}
}